package cn.rubintry.bug.hunting.common.http.api

import cn.rubintry.bug.hunting.pojo.ArticleDetailModel
import cn.rubintry.bug.hunting.pojo.ArticleModel
import cn.rubintry.bug.hunting.pojo.BaseModel
import cn.rubintry.bug.hunting.pojo.HistoryModel
import cn.rubintry.bug.hunting.pojo.HomeBackgroundModel
import cn.rubintry.bug.hunting.pojo.TagDataModel
import cn.rubintry.bug.hunting.pojo.UserDataModel
import cn.rubintry.bug.hunting.pojo.VerifyCodeModel
import cn.rubintry.bug.hunting.pojo.VersionDataModel
import cn.rubintry.bug.lib.network.http.NetWorkService
import retrofit2.http.Field
import retrofit2.http.FormUrlEncoded
import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.Query


interface WebApi : NetWorkService {

    /**
     * 分页获取文章
     */
    @GET("/v2/article/getArticleWithLimit")
    suspend fun getArticleWithLimit(
        @Query("start") start: String,
        @Query("limit") limit: String
    ): BaseModel<List<ArticleModel>>


    /**
     * 获取文章详情
     */
    @FormUrlEncoded
    @POST("/v2/article/getArticleDetailById")
    suspend fun getArticleById(@Field("id") id: String) : BaseModel<ArticleDetailModel>


    /**
     * 获取首页背景图片
     */
    @GET("/v2/common/getHomeBackgroundImages")
    suspend fun getHomeBackgroundImages():BaseModel<List<HomeBackgroundModel>>


    /**
     * 获取首页banner图片
     */
    @GET("/v2/common/getMobileBannerImages")
    suspend fun getMobileBannerImages():BaseModel<List<HomeBackgroundModel>>



    /**
     * 获取验证码
     */
    @POST("/v2/common/getVerifyCode")
    suspend fun getVerifyCode() : BaseModel<VerifyCodeModel>


    /**
     * 登录
     */
    @FormUrlEncoded
    @POST("/v2/user/login")
    suspend fun login(
        @Field("userName") userName: String,
        @Field("password") password: String,
        @Field("uuid") uuid: String,
        @Field("verifyCode") verifyCode: String,
    ): BaseModel<UserDataModel>


    /**
     * 获取热门标签
     */
    @POST("/v2/common/getHotTags")
    suspend fun getTags() : BaseModel<List<TagDataModel>>


    /**
     * 根据标签查文章
     */
    @FormUrlEncoded
    @POST("/v2/article/getSourceFromTag")
    suspend fun getSourceFromTag(@Field("tagIds") tagIds: String): BaseModel<List<ArticleModel>>


    /**
     * 添加文章到历史记录
     */
    @FormUrlEncoded
    @POST("/history/addArticleToHistory")
    suspend fun addToHistory(@Field("userId") userId:String,
                             @Field("articleId") articleId: String,
                             @Field("title") title: String ,
                             @Field("sampleContent") sampleContent: String,
                             @Field("token") token: String) : BaseModel<String>


    /**
     * 获取
     */
    @FormUrlEncoded
    @POST("/history/getHistory")
    suspend fun getHistory(@Field("userId") userId: String,@Field("token") token: String) : BaseModel<List<HistoryModel>>



    @POST("/app/getLastVersion")
    suspend fun getLastVersion() : BaseModel<VersionDataModel>

}